﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using FangPage.Core;
using FangPage.Common;
using FangPage.Data;
using System.IO;
using ProjectManager.User.Model;
using System.Data.Common;

namespace ProjectManager.User.Controller
{
    public class menu_list : FPController
    {
        public override void Controller()
        {
            AuthInfo authinfo = Logins.Authorize();

            if (!authinfo.islogin)
            {
                FPResponse.WriteErr("对不起，您尚未登录或登录超时！");
                return;
            }

            if (ispost)
            {
                string ids = FPRequest.GetString("ids");

                DbHelper.ExcuteDelete<MenuInfo>(ids);

                FPResponse.WriteSuccess("删除成功");
            }

            SqlParam menu_sql = DbHelper.MakeOrderBy("sortindex", OrderBy.ASC);

            List<MenuInfo> data = DbHelper.ExcuteList<MenuInfo>(menu_sql);

            FPResponse.WriteData(data);
        }
    }
}
